import java.util.Scanner;

public class Main {
    //代码示例4 求斐波那契数列的第 N 项
    public static int  Fib(int x){
        if(x==1||x==2){
            return 1;
        }
        return Fib(x-1)+Fib(x-2);
    }
    public static void main(String[] args) {
        int x=5;
        System.out.println(Fib(x));
    }
    //代码示例3 写一个递归方法，输入一个非负整数，返回组成它的数字之和. 例如，输入 1729, 则应该返回
    //1+7+2+9，它的和是19
    public static int sum(int x){
        if(x<=9){
            return x;
        }
        return x%10+sum(x/10);
    }
    public static void main8(String[] args) {
        int x=1729;
        int ret=sum(x);
        System.out.println(ret);
    }
    //按顺序打印一个数字的每一位(例如 1234 打印出 1 2 3 4)
    public static void Print(int x){
        if(x>9){
            Print(x/10);
        }
        System.out.println(x%10);
    }
    public static void main7(String[] args) {
        Print(1234);
    }
    //阶乘
    public static int func(int x){
        if(x==1){
            return 1;
        }
        return x*func(x-1);
    }
    public static void main6(String[] args) {
        int n=5;
        int ret=func(n);
        System.out.println(ret);
    }
    public static int Add(int x,int y){
        return x+y;
    }
    public static double Add(double x,double y){
        return x+y;
    }
    public static int Add(int x,int y,int z){
        return x+y+z;
    }

    public static int AddInt(int x,int y){
        return x+y;
    }
    public static double AddDou(double x,double y){
        return x+y;
    }
    public static int AddTri(int x,int y,int z){
        return x+y+z;
    }
    public static void main5(String[] args) {
        System.out.println(Add(10, 20));
        System.out.println(Add(10.2, 14.3));
        System.out.println(Add(10, 20, 30));
    }
    public static void Swap(int x,int y){
        int tmp=x;
        x=y;
        y=tmp;
    }

    public static void main4(String[] args) {
        int x=10;
        int y=20;
        System.out.printf("交换前的x:%d,y:%d\n",x,y);
        Swap(x,y);
        System.out.printf("交换后的x:%d,y:%d\n",x,y);
    }
    /*public static int Add(int x,int y){
        return x+y;
    }
    public static void main3(String[] args) {
        System.out.println(Add(10, 20));
    }*/
    public static void isPrimeNum(int n){
        int i = 2;
        for (; i <=Math.sqrt(n); i++) {
            if(n%i==0){
                break;
            }
        }
        if (i > Math.sqrt(n)) {
            System.out.println(n+"是素数");
        }else{
            System.out.println(n+"不是素数");
        }
    }
    public static void main2(String[] args) {
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        isPrimeNum(x);
    }
    //判断是否是闰年
    public static boolean isLeapYear(int y){
        if(y%400==0||(y%4==0&&y%100!=0)){
            return true;
        }else {
            return false;
        }
    }
    public static void main1(String[] args) {
        Scanner sc=new Scanner(System.in);
        int y=sc.nextInt();
        if(isLeapYear(y)==true){
            System.out.println(y+"年"+"是闰年");
        }else {
            System.out.println(y+"年"+"不是闰年");
        }
    }
}